<template>
  <div class="priceingBackDialog">
    <el-dialog title="整改审核" :visible.sync="isShow" width="30%" center>
      <!-- <h3 class="tc mb20">
        <span class="mr10">{{ orderDetail.order_number }}</span
        >{{ orderDetail.patent_name }}
      </h3> -->
      <el-form :model="form" :rules="rules" ref="formRef" label-width="100px">
        <el-form-item label="审核意见" prop="approval_opinion">
          <el-input
            v-model="form.approval_opinion"
            maxlength='200'
            show-word-limit
            type="textarea"
            :autosize="{ minRows: 2, maxRows: 4 }"
          ></el-input>
        </el-form-item>
          <el-form-item label="奖励金额" prop="reward_money"  v-if='approval_status==1'>
          <el-input
            v-model="form.reward_money"
            type="number"
         
          ></el-input>
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button  v-no-more-click:3000  :type="this.approval_status==1?'primary':'warning'" @click="confrim">{{this.approval_status==1?"通过":"驳回"}}</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { sceneRecordApprovalStatus } from "@a/user";
import { MessageBox, Message } from "element-ui";
export default {
  data() {
    return {
      isShow: false,
      form: {
        approval_opinion: "",
        reward_money:''
      },
      rules: {
        approval_opinion: [{ message: "请输入审核意见", trigger: "blur" }],
         reward_money: [{  message: "请输入奖励金额", trigger: "blur" }]
      },
      approval_status:"1",
      id: null,
      orderDetail: {},
    };
  },
  methods: {
    
    cancel() {
      this.isShow = false;
   
   this.form.approval_opinion=''
        this.form.reward_money=''
     
    },
    confrim() {
      this.$refs["formRef"].validate((valid) => {
        if (valid) {
          this.submit();
        } else {
          return false;
        }
      });
    },
    submit() {
      var  params = {
        approval_status: this.approval_status,
        id:this.id
      }
      if(this.form.approval_opinion.trim() !=''){
   
params.approval_opinion=this.form.approval_opinion

      }
        if(this.form.reward_money.trim() !=''){
               if(this.form.reward_money <0){
      
           this.$message({
          message: '奖赏金额请输入大于0的数',
          type: 'warning'
        });
        return
        }
     
params.reward_money=this.form.reward_money
      }
      sceneRecordApprovalStatus(params).then((res) => {
        if (res.code == 200) {
          
          Message({
            message:`${this.approval_status==1?'通过':'驳回'}成功`,
            type: 'success'
          })
          this.$emit("refresh");
          this.cancel();
        }
      });
    },
    show(approval_status,id) {
      this.id = id;
      this.approval_status = approval_status;

      this.isShow = true;
    },
  },
};
</script>

<style lang="less" scoped>
.priceingBackDialog {
  /deep/.el-dialog {
    min-width: 500px;
  }
}
</style>
